package histogram;

import histogram.pixelprocessor.GrayscaleStatistics;

import java.awt.image.BufferedImage;

import core.SimpleImageProcessor;

public class GrayscaleHistogram {

	private static GrayscaleHistogram instance = new GrayscaleHistogram();
	private SimpleImageProcessor processor = new SimpleImageProcessor();
	private GrayscaleStatistics statistics = new GrayscaleStatistics();
	private int totalPixels = 0;

	private GrayscaleHistogram() {
		processor.addPixelProcessor(statistics);
	}

	public static GrayscaleHistogram getInstance() {
		return instance;
	}

	public void grayscaleCount(BufferedImage image) {
		statistics.rest();
		processor.process(image.getData(), image.getRaster());
		totalPixels = image.getWidth() * image.getHeight();
	}

	public int getTotalPixels() {
		return totalPixels;
	}

	public int[] getGrayscaleStatistics() {
		return statistics.getStatistics();
	}
}
